package com.exam.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.exam.entity.ApiResult;
import com.exam.service.AnswerService;
import com.exam.util.ApiResultHandler;
import com.exam.vo.AnswerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/answers")
public class AnswerController {

    @Autowired
    private AnswerService answerService;

    @GetMapping("/{page}/{size}")
    public ApiResult findAllQuestion(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
       Page<AnswerVO> answerVOPage = new Page<>(page,size);
       IPage<AnswerVO> answerVOIPage = answerService.findAll(answerVOPage);
       return ApiResultHandler.buildApiResult(200,"查询所有题库",answerVOIPage);
    }

    //@GetMapping("/{questionType}/{questionId}")
    //public ApiResult findByQuestionTypeAndQuestionId(@PathVariable("questionType")
    //                                                 Integer questionType, @PathVariable("questionId") String questionId){
    //    AnswerVO answerV0 = answerService.findByQuestionTypeAndQuestionId(questionType,questionId);
    //    if (answerV0 == null) {
    //        return ApiResultHandler.buildApiResult(400,"没有这个数据",null);
    //    }
    //    return ApiResultHandler.buildApiResult(200,"查询成功",answerV0);
    //}
}
